package Dao;

import DBTool.DB;
import bean.Brand;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class brandDao {
    public static ArrayList<Brand> getbrand() {
        String sql = "select * from brand";
        ResultSet rs = DB.query(sql);
        ArrayList<Brand> list = new ArrayList<>();
        try {
            while (rs.next()) {
                int id = rs.getInt(1);
                String name = rs.getString(2);
                Brand brand = new Brand(id, name);
                list.add(brand);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return list;
    }
}
